package store.lunangangster.engine.impl.query;

import java.util.List;
import store.lunangangster.engine.impl.cmd.CommandExecutor;
import store.lunangangster.engine.impl.entity.History;
import store.lunangangster.engine.impl.interceptor.CommandContext;

public class HistoryQueryImpl extends AbstractQuery<HistoryQuery, History> implements HistoryQuery {

  protected String id;
  protected String processDefinitionId;
  protected String processDefinitionKey;
  protected boolean processDefinitionKeyLike;
  protected String processInstanceId;
  protected String processInstanceName;
  protected boolean processInstanceNameLike;
  protected String parentScopeId;
  protected String parentScopeName;
  protected boolean parentScopeNameLike;

  public HistoryQueryImpl(CommandExecutor executor) {
    super(executor);
  }

  @Override
  public HistoryQuery id(String id) {
    this.id = id;
    return this;
  }

  @Override
  public HistoryQuery processDefinitionId(String processDefinitionId) {
    this.processDefinitionId = processDefinitionId;
    return this;
  }

  @Override
  public HistoryQuery processDefinitionKey(String processDefinitionKey) {
    this.processDefinitionKey = processDefinitionKey;
    return this;
  }

  @Override
  public HistoryQuery processDefinitionKeyLike(String processDefinitionKeyLike) {
    this.processDefinitionKey = processDefinitionKeyLike;
    this.processDefinitionKeyLike = true;
    return this;
  }

  @Override
  public HistoryQuery processInstanceId(String processInstanceId) {
    this.processInstanceId = processInstanceId;
    return this;
  }

  @Override
  public HistoryQuery processInstanceName(String processInstanceName) {
    this.processInstanceName = processInstanceName;
    return this;
  }

  @Override
  public HistoryQuery processInstanceNameLike(String processInstanceNameLike) {
    this.processInstanceName = processInstanceNameLike;
    this.processInstanceNameLike = true;
    return this;
  }

  @Override
  public HistoryQuery parentScopeId(String parentScopeId) {
    this.parentScopeId = parentScopeId;
    return this;
  }

  @Override
  public HistoryQuery parentScopeName(String parentScopeName) {
    this.parentScopeName = parentScopeName;
    return this;
  }

  @Override
  public HistoryQuery parentScopeNameLike(String parentScopeNameLike) {
    this.parentScopeName = parentScopeNameLike;
    this.parentScopeNameLike = true;
    return this;
  }

  @Override
  protected List<History> queryList(CommandContext commandContext) {
    return (List<History>) commandContext.getDbSqlSession()
        .selectList("selectHistoryByCondition", this);
  }

  @Override
  protected Page<History> queryPage(CommandContext commandContext) {
    return null;
  }

  @Override
  protected int queryCount(CommandContext commandContext) {
    return 0;
  }
}
